from core import *
import matplotlib.pyplot as plt
import numpy as np
from visualizer.basic import *


def Ts(ts2, ts1, l, m, step, func):
	return TE(ts2, ts1, l, m, step, func) - TE(ts1, ts2, l, m, step, func)


def paradigm(subsequence):
	n = len(subsequence)-1
	if np.argmax(subsequence) == 0 and np.argmin(subsequence) == n:
		ans = 1
	elif np.argmax(subsequence) == n and np.argmin(subsequence) == 0:
		ans = 2
	elif np.argmax(subsequence) == 0 and np.argmin(subsequence) != n:
		ans = 3
	elif np.argmax(subsequence) == n and np.argmin(subsequence) != 0:
		ans = 4
	elif np.argmax(subsequence) != 0 and np.argmin(subsequence) == n:
		ans = 5
	elif np.argmax(subsequence) != n and np.argmin(subsequence) == 0:
		ans = 6
	else:
		ans = 7
	return ans

if __name__ == '__main__':
	ts1 = np.loadtxt('../data/pr_NY.csv')  # 降水量 # Y
	ts2 = np.loadtxt('../data/tas_NY.csv')  # 温度 # X
	N = 21
	l = 1
	m = 3
	step = 1
	# symbol
	symbol_0 = []
	x = list(range(3, N))
	for m in range(3, N):
		T = Ts(ts2, ts1, l, m, step, symbol)
		symbol_0.append(T)
	plt.plot(x, symbol_0, label='STE')
	# --------------------------------------------------------------------------------
	# par
	par = []
	for m in range(3, N):
		T = Ts(ts2, ts1, l, m, step, paradigm)
		par.append(T)
	plt.plot(x, par, label='$paradigm$')
	# --------------------------------------------------------------------------------
	plt.xlabel('$m$')
	plt.ylabel('$T(m)$')
	plt.xticks(np.arange(3, N, 3), np.arange(3, N, 3))
	plt.legend()
	plt.tight_layout()
	plt.savefig(PATH+'ParadigmTE.pdf', format='pdf')
	plt.show()
	